
import { message } from "ant-design-vue";


//loading加载
export const Loading = () => {
    const show = () => {
      document.getElementById("Loading").style.display = "block";
    };
    const remove = () => {
      document.getElementById("Loading").style.display = "none";
    };
    return { show, remove };
  };
  export const fetchData = async (api, params, loading = true) => {
    if (loading) Loading().show();
    const result = await api(params);
    if (loading) Loading().remove();
    if (result.code == "0") {
      return result.data;
    } else {
      message.destroy();
      message.error(result.message);
      throw result.message;
    }
  };